home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / share / ewl / examples / ewl_combo_test.c < prev    next >
C/C++ Source or Header  |  2006-01-09  |  3KB  |  107 lines

  1. #include "ewl_test.h"
  2.  
  3. static Ewl_Widget *combo_button = NULL;
  4.  
  5. static void
  6. __destroy_combo_test_window(Ewl_Widget *w, void *ev_data __UNUSED__, 
  7.                     void *user_data __UNUSED__)
  8. {
  9.     ewl_widget_destroy(w);
  10.     ewl_callback_append(combo_button, EWL_CALLBACK_CLICKED,
  11.                 __create_combo_test_window, NULL);
  12. }
  13.  
  14. static void
  15. __combo_value_changed(Ewl_Widget *w __UNUSED__, void *ev_data, 
  16.                     void *user_data __UNUSED__)
  17. {
  18.     Ewl_Widget *entry;
  19.     char *text;
  20.  
  21.     entry = EWL_WIDGET(ev_data);
  22.     text = ewl_menu_item_text_get(EWL_MENU_ITEM(entry));
  23.  
  24.     printf("value changed to %s\n", text);
  25.     
  26.     if (!strcmp(text, "button"))
  27.     {
  28.         char *t2;
  29.         t2 = ewl_widget_data_get(entry, "dummy");
  30.         printf("with data: %s\n", t2);
  31.     }
  32.  
  33.     IF_FREE(text);
  34. }
  35.  
  36. void
  37. __create_combo_test_window(Ewl_Widget * w, void *ev_data __UNUSED__, 
  38.                     void *user_data __UNUSED__)
  39. {
  40.     Ewl_Widget     *combo_win;
  41.     Ewl_Widget     *combo_box;
  42.     Ewl_Widget     *combo1;
  43.     Ewl_Widget     *item;
  44.  
  45.     combo_button = w;
  46.  
  47.     combo_win = ewl_window_new();
  48.     ewl_window_title_set(EWL_WINDOW(combo_win), "Combo Test");
  49.     ewl_window_name_set(EWL_WINDOW(combo_win), "EWL Test Application");
  50.     ewl_window_class_set(EWL_WINDOW(combo_win), "EFL Test Application");
  51.  
  52.     if (w) {
  53.         ewl_callback_del(w, EWL_CALLBACK_CLICKED, 
  54.                         __create_combo_test_window);
  55.         ewl_callback_append(combo_win, EWL_CALLBACK_DELETE_WINDOW,
  56.                         __destroy_combo_test_window, NULL);
  57.     } else
  58.         ewl_callback_append(combo_win, EWL_CALLBACK_DELETE_WINDOW,
  59.                     __close_main_window, NULL);
  60.     ewl_widget_show(combo_win);
  61.  
  62.     /*
  63.      * Create the main box for holding the widgets
  64.      */
  65.     combo_box = ewl_vbox_new();
  66.     ewl_object_fill_policy_set(EWL_OBJECT(combo_box), EWL_FLAG_FILL_FILL);
  67.     ewl_container_child_append(EWL_CONTAINER(combo_win), combo_box);
  68.     ewl_widget_show(combo_box);
  69.  
  70.     /*
  71.      * Create the menu
  72.      */
  73.     combo1 = ewl_combo_new("test menu");
  74.     ewl_container_child_append(EWL_CONTAINER(combo_box), combo1);
  75.     ewl_callback_append(combo1, EWL_CALLBACK_VALUE_CHANGED,
  76.                 __combo_value_changed, NULL);
  77.     ewl_widget_show(combo1);
  78.  
  79.     /*
  80.      * Append some test items
  81.      */
  82.     item = ewl_menu_item_new();
  83.     ewl_menu_item_text_set(EWL_MENU_ITEM(item), "dia");
  84.     ewl_menu_item_image_set(EWL_MENU_ITEM(item),
  85.                 "/usr/share/pixmaps/dia-diagram.png");
  86.     ewl_container_child_append(EWL_CONTAINER(combo1), item);
  87.     ewl_widget_show(item);
  88.  
  89.     item = EWL_WIDGET(ewl_separator_new());
  90.     ewl_container_child_append(EWL_CONTAINER(combo1), item);
  91.     ewl_widget_show(item);
  92.  
  93.     item = ewl_menu_item_new();
  94.     ewl_menu_item_text_set(EWL_MENU_ITEM(item), "gimp");
  95.     ewl_menu_item_image_set(EWL_MENU_ITEM(item),
  96.                 "/usr/share/pixmaps/wilber.png");
  97.     ewl_container_child_append(EWL_CONTAINER(combo1), item);
  98.     ewl_widget_show(item);
  99.  
  100.     item = ewl_menu_item_new();
  101.     ewl_menu_item_text_set(EWL_MENU_ITEM(item), "button");
  102.     ewl_widget_data_set(item, "dummy", "data");
  103.     ewl_container_child_append(EWL_CONTAINER(combo1), item);
  104.     ewl_widget_show(item);
  105. }
  106.  
  107.